<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let salaries = {
        John: 100,
        Ann: 160,
        Pete: 130,
      };

      function max(obj) {
        let n = 0;
        let name = "";
        for (let k in obj) {
          if (n < obj[k]) {
            n = obj[k]; //n保存的永远都是最大值
            name = k;
          }
        }
        return name;
      }
      console.log(max(salaries));
    </script>
  </body>
</html>
